package com.etoak.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {
    public static final String EXCHANGE="amqp.test.topic";
    public static final String QUEUE_3="q3";
    public static final String QUEUE_4="q4";
    public static final String ORANGE="*.orange.*";
    public static final String RABBIT ="*.*.rabbit";
    public static final String LAZY = "lazy.#";

    @Bean
    public TopicExchange TopicExchange() {
        return new TopicExchange(EXCHANGE);
    }
    @Bean
    public Queue Queue3() {
        return new Queue(QUEUE_3);
    }
    @Bean
    public Queue Queue4() {
        return new Queue(QUEUE_4);
    }

    @Bean
    public Binding queue3Binding(Queue Queue3, TopicExchange TopicExchange) {
        return BindingBuilder.bind(Queue3).to(TopicExchange).with(ORANGE);

    }

    @Bean
    public Binding rabbitBinding(Queue Queue4, TopicExchange TopicExchange) {
        return BindingBuilder.bind(Queue4).to(TopicExchange).with(RABBIT);

    }

    @Bean
    public Binding lazyBinding(Queue Queue4, TopicExchange TopicExchange) {
        return BindingBuilder.bind(Queue4).to(TopicExchange).with(LAZY);
    }
}
